package android.medicalcloud.com.yiapp.yilian.utils.android;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.medicalcloud.com.yiapp.yilian.application.YilianAppcation;
import android.medicalcloud.com.yiapp.yilian.logic.UserController;
import android.medicalcloud.com.yiapp.yilian.model.OrderModel;
import android.medicalcloud.com.yiapp.yilian.model.PatitentModel;
import android.medicalcloud.com.yiapp.yilian.ui.FindPassActivity;
import android.medicalcloud.com.yiapp.yilian.ui.MainPageActivity;
import android.medicalcloud.com.yiapp.yilian.ui.OrderDetailActivity;
import android.medicalcloud.com.yiapp.yilian.ui.PatientDetailActivity;
import android.medicalcloud.com.yiapp.yilian.ui.ac.AvatarActivity;
import android.medicalcloud.com.yiapp.yilian.ui.ac.CropImageActivity;
import android.medicalcloud.com.yiapp.yilian.ui.ac.LoginActivity;
import android.medicalcloud.com.yiapp.yilian.ui.ac.PersonDetialActivity;
import android.medicalcloud.com.yiapp.yilian.ui.ac.SubmitAvatarActivity;
import android.medicalcloud.com.yiapp.yilian.ui.ac.UpdatePassActivity;
import android.medicalcloud.com.yiapp.yilian.ui.ac.WebViewActivity;
import android.net.Uri;
import android.transition.Fade;
import android.transition.Transition;

import com.tencent.TIMCallBack;
import com.tencent.qcloud.presentation.business.LoginBusiness;

/**
 * Created by wanggenlin on 16-11-22.
 * enter ac dex
 */
public class IntentTool {

    public static void startMain(Context context) {
        Intent intent = new Intent(context, MainPageActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        context.startActivity(intent);
    }

    public static void startMain(Context context,int currentIndex) {
        Intent intent = new Intent(context, MainPageActivity.class);
        intent.putExtra("index",currentIndex);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        context.startActivity(intent);
    }

    public static void loginClearTop(Context context) {
        YilianAppcation.instance.clear();
        UserController.getInstance().saveToken("");
        Intent intent = new Intent(context, LoginActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        LoginBusiness.logout(new TIMCallBack() {
            @Override
            public void onError(int i, String s) {

            }

            @Override
            public void onSuccess() {

            }
        });
        context.startActivity(intent);
    }


    public static void login(Context context) {
        Intent intent = new Intent(context, LoginActivity.class);
        context.startActivity(intent);
    }

    public static void findPassword(Context context) {
        Intent intent = new Intent(context, FindPassActivity.class);
        context.startActivity(intent);
    }
    public static void updatePassword(Context context) {
        Intent intent = new Intent(context, UpdatePassActivity.class);
        context.startActivity(intent);
    }
    public static void orderDetail(Context context, OrderModel model) {
        Intent intent = new Intent(context, OrderDetailActivity.class);
        intent.putExtra("m",model);
        context.startActivity(intent);
    }

    public static void patient(Context context, PatitentModel model) {
        Intent intent = new Intent(context, PatientDetailActivity.class);
        intent.putExtra("m",model);
        context.startActivity(intent);
    }


    public static void webview(Context context,String url,String title) {
        Intent intent = new Intent(context, WebViewActivity.class);
        intent.putExtra("url",url);
        intent.putExtra("title",title);
        context.startActivity(intent);
    }
    public static void call(Context context,String phone) {
        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"+phone));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    }


    public static void person(Context context) {
        Intent intent = new Intent(context, PersonDetialActivity.class);
        context.startActivity(intent);
    }

    public static void startSubmitAvatar(Context context, String url) {
        Intent intent = new Intent(context, SubmitAvatarActivity.class);
        intent.putExtra("url", url);
        context.startActivity(intent);
    }

    public static void startCropImage(Activity activity, String uri, int outputX, int outputY, int requestCode) {
        Intent intent = new Intent(activity, CropImageActivity.class);
        intent.putExtra(CropImageActivity.IMAGE_PATH, uri);
        intent.putExtra(CropImageActivity.OUTPUT_X, outputX);
        intent.putExtra(CropImageActivity.OUTPUT_Y, outputY);
        activity.startActivityForResult(intent, requestCode);
    }



    public static void startAvatar(Context context, String url) {
        Intent intent = new Intent(context, AvatarActivity.class);
        intent.putExtra("url", url);
        context.startActivity(intent);
    }




}

